import { default as request, cloud } from '@/framework/utils/request'

export default ({

  // 获取角色列表
  fetchList(params) {
    return request({
      url: cloud.permission + '/sysRole/page',
      method: 'get',
      params
    })
  },

  // 添加角色
  addRole(data) {
    return request({
      url: cloud.dqbasic + '/sysRole/add',
      method: 'post',
      data
    })
  },

  // 获取角色数据
  getRoleById(id) {
    return request({
      url: cloud.dqbasic + '/sysRole/detail',
      method: 'get',
      params: {
        'roleId': id
      }
    })
  },

  // 修改角色
  updateRole(data) {
    return request({
      url: cloud.dqbasic + '/sysRole/edit',
      method: 'post',
      data
    })
  },

  // 删除角色
  deleteRole(id) {
    return request({
      url: cloud.dqbasic + '/sysRole/delete',
      method: 'post',
      data: {
        'roleId': id
      }
    })
  },
  // 编辑数据范围
  grantDataScope(data) {
    return request({
      url: cloud.dqbasic + '/sysRole/grantDataScope',
      method: 'post',
      data
    })
  },

  // 获取组织树
  roleBindOrgScope(id) {
    return request({
      url: cloud.dqbasic + '/hrOrganization/roleBindOrgScopeAntdv',
      method: 'get',
      params: {
        'roleId': id
      }
    })
  },
  // 获取组织树(懒加载)
  roleBindOrgScopeLazyAntdv(data) {
    return request({
      url: cloud.dqbasic + '/hrOrganization/roleBindOrgScopeLazyAntdv',
      method: 'get',
      params: data
    })
  },

  // 分配菜单按钮
  grantMenuAndButton(data) {
    return request({
      url: cloud.dqbasic + '/sysRole/grantMenuAndButton',
      method: 'post',
      data
    })
  },

  // 获取菜单树
  menuAndButtonTree(id) {
    return request({
      url: cloud.dqbasic + '/sysMenu/menuAndButtonTreeChildren',
      method: 'get',
      params: {
        'roleId': id
      }
    })
  },

  // 获取接口树
  getRoleResourceTree(id) {
    return request({
      url: cloud.dqbasic + '/resource/getRoleResourceTreeAntdv',
      method: 'get',
      params: {
        'roleId': id
      }
    })
  },

  // 分配接口
  grantResource(data) {
    return request({
      url: cloud.dqbasic + '/sysRole/grantResource',
      method: 'post',
      data
    })
  },

  dropDown(params) {
    return request({
      url: cloud.dqbasic + '/sysRole/dropDown',
      method: 'get',
      params
    })
  }

})

